<header id="topbar" class="affix">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="<%= window.location.href %>">红包模板详情</a>
            </li>
            <li class="crumb-link">
                <a href="#op/coupon_tmpl/">红包模板管理</a>
            </li>
            <li class="crumb-trail">红包模板编辑</li>
        </ol>
    </div>
    <div class="pull-right">
        <a href="javascript:;" class="btn btn-primary btn-sm light fw600 ml10" id='couponTemplateSave'><span
                class="fa fa-save"></span> 保存 </a>
    </div>
</header>

<section id="content">
    <div class="panel">
        <form id="coupon-template-form" class="form-horizontal" role="form">
            <div class="form-group">
                <label for="inputTitle" class="col-md-1 control-label">红包标题：</label>
                <div class="col-md-5">
                    <input type="text" id="inputTitle" class="form-control" value="<%= title %>"
                           placeholder="请输入红包标题..." required>
                </div>
                <label for="inputDesc" class="col-md-1 control-label">红包描述：</label>
                <div class="col-md-5">
                    <input type="text" id="inputDesc" class="form-control" value="<%= desc %>" placeholder="请输入红包描述..."
                           required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-1 control-label" for="inputPrice">金额:</label>
                <div class="col-md-5">
                    <input type="number" id="inputPrice" class="form-control" value="<%= price %>" required>
                </div>
                <label class="col-md-1 control-label" for="inputConditionPrice">条件金额:</label>
                <div class="col-md-5">
                    <input type="number" id="inputConditionPrice" class="form-control" value="<%= condition_price %>"
                           required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-1 control-label" for="inputConditionPrice">红包类型:</label>
                <div class="col-md-5">
                    <select id="inputCouponType" class="form-control">
                        <option value="1"
                        <%= coupon_type == 1 ? 'selected' : '' %>>直减</option>
                        <option value="2"
                        <%= coupon_type == 2 ? 'selected' : '' %>>满减</option>
                    </select>
                </div>
                <label for="inputValidTs" class="col-md-1 control-label">有效期:</label>
                <div class="col-md-5">
                    <select id="inputValidTs" class="form-control">
                        <% var d = valid_ts/60/60/24;%>
                        <option value="0"
                        <%= d == 0 ? "selected" : "" %>>当天</option>
                        <option value="1"
                        <%= d == 1 ? "selected" : "" %>>1天</option>
                        <option value="2"
                        <%= d == 2 ? "selected" : "" %>>2天</option>
                        <option value="3"
                        <%= d == 3 ? "selected" : "" %>>3天</option>
                        <option value="4"
                        <%= d == 4 ? "selected" : "" %>>4天</option>
                        <option value="5"
                        <%= d == 5 ? "selected" : "" %>>5天</option>
                        <option value="6"
                        <%= d == 6 ? "selected" : "" %>>6天</option>
                        <option value="7"
                        <%= d == 7 ? "selected" : "" %>>7天</option>
                    </select>
                </div>
            </div>
            <br> <br>
            <div class="form-group">
                <label for="inputActivityType" class="col-md-1 control-label">限定彩种:</label>
                <div class="col-md-5">
                    <select data-field="activity_type" id="inputActivityType" class="form-control multiselect"
                            onchange="generate_cmd();">
                        <option value="0">全部</option>
                        <% _.each(window.LOTTERY_TYPE, function(v, k){ %>
                        <option value="<%= k %>"
                        <%= activity_type==k ? "selected" : "" %> ><%= v %></option>
                        <% }) %>
                    </select>
                </div>
                <label for="inputActivityType" class="col-md-1 control-label">玩法</label>
                <div class="col-md-4">
                    <select data-type="int" data-field="bet_type" class="form-control" id="betType" onchange="generate_cmd();">
                        <option value="0">无</option>
                        <% _.each(window.BET_TYPE[activity_type], function(v, k){ %>
                            <option value="<%= k %>" <%= parseInt(bet_type) == k ? "selected" : "" %> > <%= v %> </option>
                        <% }) %>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="inputRemark" class="col-md-1 control-label">remark:</label>
                <div class="col-md-5">
                    <input type="text" id="inputRemark" class="form-control" placeholder="新建时会自动生成,可以自定义"
                    value="<%= remark %>">
                </div>
                <label for="inputCmd" class="col-md-1 control-label">cmd</label>
                <div class="col-md-5">
                    <input placeholder="新建时会自动生成,可以自定义" type="text" id="inputCmd" class="form-control"
                           value="<%= cmd %>">
                </div>
            </div>
        </form>
    </div>
</section>

<section>
    <article>
        <p>
            "CQ_SSC": (1L, u"重庆时时彩"),
        </p>
        <p>
            "HN_YFC": (2L, u"河内一分彩"),
        </p>
        <p>
            "JS_KS": (3L, u"江苏快3"),
        </p>
        <p>
            "SD_11X5": (4L, u"山东11选5"),
        </p>
        <p>
            "HN_WFC": (5L, u"河内五分彩"),
        </p>
        <p>
            "TJ_SSC": (6L, u"天津时时彩"),
        </p>
        <p>
            "XJ_SSC": (7L, u"新疆时时彩"),
        </p>
        <p>
            "JX_11X5": (8L, u"江西11选5"),
        </p>
        <p>
            "GD_11X5": (9L, u"广东11选5"),
        </p>
        <p>
            "SH_11X5": (10L, u"上海11选5"),
        </p>
        <p>
            "GX_KS": (11L, u"广西快3"),
        </p>
        <p>
            "BJ_PK10": (12L, u"北京PK10"),
        </p>
        <p>
            "CQ_LF": (13L, u"重庆幸运农场")
        </p>
    </article>
</section>

<script>
    function generate_cmd() {
        var type = $('#inputActivityType').val();
        var bet_type = $('#betType').val();
        if (type == 0) {
            $('#inputCmd').val('');
            $('#inputRemark').val('全场通用');
        } else {
            $('#inputCmd').val('xingyuncp://open/bet?activity=' + type + '&betType=' + bet_type);
            var activity = window.LOTTERY_TYPE[type];
            if (bet_type != 0) {
                var playtype = window.BET_TYPE[type][bet_type];
                $('#inputRemark').val('仅限' + activity + '的' + playtype + '使用');
            }
            else {
                $('#inputRemark').val('仅限' + activity + '使用');
            }
        }
    }
</script>
